package com.hqyj.javaGraduation.hotel.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hqyj.javaGraduation.hotel.dao.HotelMaterialsBillDao;
import com.hqyj.javaGraduation.hotel.dao.HotelMaterialsDao;

import com.hqyj.javaGraduation.hotel.pojo.HotelMaterials;
import com.hqyj.javaGraduation.hotel.pojo.HotelMaterialsBill;
import com.hqyj.javaGraduation.hotel.service.HotelMaterialsBillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;

/**
 * 订单impl
 */
@Service
public class HotelMaterialsBillServiceImpl implements HotelMaterialsBillService {
    Date date=new Date();
    @Autowired
    HotelMaterialsDao hotelMaterialsDao;
    @Autowired
    HotelMaterialsBillDao hotelMaterialsBillDao;
    //进货
    @Override
    public HashMap<String, Object> Stock(HotelMaterialsBill hotelMaterialsBill) {
        HashMap<String,Object> map=new HashMap<>();
        hotelMaterialsBill.setBillTime(date);
        HotelMaterials hotelMaterials=hotelMaterialsDao.selectById(hotelMaterialsBill.getMatId());
        return null;
    }
    //退货
    @Override
    public HashMap<String, Object> Returns(HotelMaterialsBill hotelMaterialsBill) {
        return null;
    }
    //领料
    @Override
    public HashMap<String, Object> Receive(HotelMaterialsBill hotelMaterialsBill) {
        return null;
    }
    //删除订单
    @Override
    public HashMap<String, Object> delMatBill(Integer id) {
        return null;
    }
    //账单分页列表
    @Override
    public HashMap<String, Object> matBillList(HotelMaterialsBill hotelMaterialsBill) {
        HashMap<String, Object> map = new HashMap<String, Object>();
        //第一步：创建分页对象
        Page<HotelMaterialsBill> hotelMaterialsBillPage = new Page<>(hotelMaterialsBill.getPage(), hotelMaterialsBill.getRow());
        //创建查询条件对象
        QueryWrapper<HotelMaterialsBill> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(
                hotelMaterialsBill.getMatName() != null && !hotelMaterialsBill.getMatName().equals(""),
                "mat_name",
                hotelMaterialsBill.getMatName());
        //第二步：查询分页，获取分页数据集
        Page<HotelMaterialsBill> pageList = hotelMaterialsBillDao.selectPage(hotelMaterialsBillPage, queryWrapper);
        //获取当前页的集合
        map.put("info", pageList.getRecords());
        //获取总条数
        map.put("total", pageList.getTotal());
        //获取总页数
        map.put("totalPage", pageList.getPages());
        return map;
    }
    @Override
    public HashMap<String, Object> delBill(int id) {
        HashMap<String, Object> map = new HashMap<>();
        int num = hotelMaterialsBillDao.deleteById(id);
        if (num > 0) {
            map.put("info", "删除成功");
        } else {
            map.put("info", "删除失败");
        }
        return map;
    }
}
